function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return unescape(r[2]);
    }
    return null;
}
if (getQueryString("success_user") == 1) {
    alert("账号修改成功！！！");
}
if (getQueryString("success_pwd") == 1) {
    alert("密码修改成功！！！");
}
function checkForm() {
    //判断用户输入的登录名与密码
    var userName = document.getElementById("username").value;
    var passWord = document.getElementById("password").value;
    if (userName == null || userName == "") {
        document.getElementById("error").innerHTML = "用户名不能为空";
        return false;
    }
    if (passWord == null || passWord == "") {
        document.getElementById("error").innerHTML = "密码不能为空";
        return false;
    }
    if (userName != null && userName != "" && passWord != null && passWord != "") {
        // 1.创建对象
        const xhr = new XMLHttpRequest();
        // 3.初始化 设置请求方法和url
        xhr.open('POST', 'login?action=ajax&&username=' + userName + '&&password=' + passWord, true);
        // 4.发送
        xhr.send();
        // 2.事件绑定，待接收服务端结果
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300) {
                if (xhr.response) {
                    document.getElementById("error").innerHTML = xhr.response;
                    return false;
                } else {
                    document.getElementById('login').action = "login";
                    document.getElementById('login').submit();
                    return true;
                }
            }
        }
    }
}